//判断是否有token 如果没有则返回至login页面
if (!localStorage.getItem('token')) {
  location.href = './login.html'
}

// 点击退出登录
document.querySelector('#logout').addEventListener('click', function () {
  localStorage.clear()
  location.href = './login.html'
})

// 渲染用户名
document.querySelector('.username').innerHTML = localStorage.getItem('username')